// API配置管理
const API_CONFIG = {
  development: {
    baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:5001/api',
    timeout: 30000,
    retryCount: 3,
    retryDelay: 1000
  },
  production: {
    baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
    timeout: 30000,
    retryCount: 3,
    retryDelay: 1000
  },
  test: {
    baseURL: 'http://localhost:5001/api',
    timeout: 30000,
    retryCount: 3,
    retryDelay: 1000
  }
}

// 获取当前环境配置
function getCurrentConfig() {
  const env = process.env.NODE_ENV || 'development'
  return API_CONFIG[env] || API_CONFIG.development
}

// API端点定义
const API_ENDPOINTS = {
  // 热点数据相关
  HOTSPOTS: '/hotspots',
  REFRESH_HOTSPOTS: '/hotspots/refresh',
  FETCH_NOW: '/hotspots/fetch-now',
  
  // 文案生成相关
  COPYWRITING_GENERATE: '/copywriting/generate',
  COPYWRITING_HISTORY: '/copywriting/history',
  
  // 趋势分析相关
  TRENDS_ANALYZE: '/trends/analyze',
  TRENDS_WORDCLOUD: '/trends/wordcloud',
  TRENDS_STATS: '/trends/stats',
  
  // 发布相关
  PUBLISH_EXECUTE: '/publish/execute',
  PUBLISH_TEST: '/publish/test',
  
  // 系统相关
  HEALTH_CHECK: '/health',
  SYSTEM_INFO: '/system/info'
}

// 获取完整的API URL
function getApiUrl(endpoint) {
  const config = getCurrentConfig()
  return `${config.baseURL}${endpoint}`
}

export {
  API_CONFIG,
  API_ENDPOINTS,
  getCurrentConfig,
  getApiUrl
}
